package com.woniuxy.threadmethods;

import lombok.extern.slf4j.Slf4j;
import org.openjdk.jol.info.ClassLayout;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 偏向锁
 * <P> Date: 2022/4/7:10:57
 * <P> Description:
 */
@Slf4j(topic = "c.TestBiased")
public class TestBiased {
    public static void main(String[] args) throws InterruptedException {
        Dog dog = new Dog();
        dog.hashCode();

        //TODO
        //      0     4        (object header)                           01 00 00 00 (00000001 00000000 00000000 00000000) (1)
        //      4     4        (object header)                           00 00 00 00 (00000000 00000000 00000000 00000000) (0)
        //      8     4        (object header)                           a4 8b 01 f8 (10100100 10001011 00000001 11111000) (-134116444)
       //   101 偏向锁
        System.out.println(ClassLayout.parseInstance(dog).toPrintable());

        synchronized (dog){
            System.out.println(ClassLayout.parseInstance(dog).toPrintable());
        }

        System.out.println(ClassLayout.parseInstance(dog).toPrintable());

    }
}

class Dog{

}
